package com.example.education.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.education.Bean.News;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 姚
 * @since 2023-04-12
 */

@Mapper
public interface NewsMapper extends BaseMapper<News> {

    //增
    @Insert("INSERT into news (uid,news_title,news_content,news_time) values (#{uid},#{newsTitle},#{newsContent},#{newsTime})")
    int insert(News news);

    //查所有相应地区的所有新闻
    @Select("SELECT * FROM news WHERE country=#{country}")
    ArrayList<News> selectAll(String country);

    //查出所有新闻
    @Select("SELECT * FROM news")
    ArrayList<News> selectAllNews();

    //根据你现在的留学阶段查出对应阶段的新闻
    @Select("SELECT * FROM news WHERE stage=#{stage}")
    ArrayList<News> recommendNewsByStage(String stage);


}
